package ctrl

import (
	"cyiris/app/demo/biz"
	"cyiris/app/demo/models"
	"cyiris/core/mq"
	log "cyiris/core/zaplog"
	"encoding/json"
	"fmt"
)

type DemoTaskCtrl struct {
	mq.Ctrl
	biz *biz.TestTaskBiz
}

func NewDemoTaskCtrl() *DemoTaskCtrl {
	c := &DemoTaskCtrl{
		Ctrl: mq.NewBaseCtrl(),
		biz:  biz.NewTestTaskBiz(),
	}

	return c
}

func (ctrl *DemoTaskCtrl) Action(ctx *mq.Context) {
	log.Debugf("handle demo task ctrl")

	msgHeader := ctx.TaskMsg.GetHeader()
	msgBody := ctx.TaskMsg.GetBody()

	user := models.TUser{}
	json.Unmarshal(msgBody, &user)

	fmt.Println(msgHeader, string(msgBody), user)
}
